package org.TCPcase5;

import java.io.*;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
//        目标：模拟一个用户选择一个文件发送个服务端（重复运行就是多个用户多次发送）
        Socket user=new Socket("127.0.0.1",10086);
        BufferedInputStream bis=new BufferedInputStream(new FileInputStream("C:\\Users\\夏明毅\\Desktop\\java课程代码\\mySocketnet\\clientDir\\xmy.text"));
        BufferedOutputStream bos=new BufferedOutputStream(user.getOutputStream());
        byte [] bytes=new byte[1024];
        int len=0;
        while ((len=bis.read(bytes))!=-1){
            bos.write(bytes,0,len);
            bos.flush();
        }
        user.shutdownOutput();
        BufferedReader br=new BufferedReader(new InputStreamReader(user.getInputStream()));
        String s = br.readLine();
        System.out.println(s);
        user.close();
    }
}
